import { NgModule } from '@angular/core';
import { FrameworkComponent } from './framework.component';
import { StorageService } from '../shared/services/storage.service';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { AuthGuard } from '../guards/auth.guard';
import { BsDropdownModule, CollapseModule } from 'ngx-bootstrap';
import { LrtmService } from './lrtm/lrtm.service';
import { LrtmComponent } from './lrtm/lrtm.component';
import { TaskComponent } from './lrtm/task/task.component';

const routes: Routes = [
    {
        path: '',
        component: FrameworkComponent,
        children: [
            {
                path: '',
                redirectTo: 'home',
                pathMatch: 'full'
            },
            {
                path: 'home',
                loadChildren: '../modules/home/home.module#HomeModule',
                data: { preload: true },
                canActivate: [AuthGuard]
            },
            {
                path: 'management',
                loadChildren: '../modules/userManagement/userManagement.module#UserManagementModule',
                data: { preload: false },
                canActivate: [AuthGuard]
            },
            {
                path: 'knowledge',
                loadChildren: '../modules/knowledgeCenter/knowledgeCenter.module#KnowledgeCenterModule',
                data: { preload: false },
                canActivate: [AuthGuard]
            },
            {
                path: 'tools',
                loadChildren: '../modules/misc/tools.module#ToolsModule',
                data: { preload: false },
                canActivate: [AuthGuard]
            },
            {
                path: 'ftp',
                loadChildren: '../modules/ftpReports/ftpReports.module#FtpReportsModule',
                data: { preload: false },
                canActivate: [AuthGuard]
            },
            {
                path: 'governance',
                loadChildren: '../modules/governanceReports/governanceReports.module#GovernanceReportsModule',
                data: { preload: false },
                canActivate: [AuthGuard]
            },
            {
                path: 'reports',
                loadChildren: '../modules/reporting/reporting.module#ReportingModule',
                data: { preload: false },
                canActivate: [AuthGuard]
            },
            {
                path: 'validation',
                loadChildren: '../modules/validation/validation.module#ValidationModule',
                canActivate: [AuthGuard]
            },
            {
                path: 'weightmatrices',
                loadChildren: '../modules/weightMatrices/weightMatrices.module#WeightMatricesModule'
            }
        ]
    }
];

/**
 * Framework module
 *
 * Author: Sorin Spiru
 * Date: 13.01.2018
 */
@NgModule({
    providers: [
        StorageService,
        LrtmService
    ],
    imports: [
        CommonModule,
        RouterModule.forChild(routes),
        BsDropdownModule.forRoot(),
        CollapseModule.forRoot()
    ],
    declarations: [
        FrameworkComponent,
        LrtmComponent,
        TaskComponent
    ],
    exports: [
        FrameworkComponent
    ]
})
export class FrameworkModule { }
